﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class KnowledgeText : MonoBehaviour
{
    public GameObject parentBut;
    public GameObject but;
    GameObject data;
    int a;
    string[] namestring = { "概论", "线性表", "栈和队列", "串", "多维数组", "树", "图" };
    // Start is called before the first frame update
    void Start()
    {
        data = GameObject.FindGameObjectWithTag("Data");
        a = data.GetComponent<GameData>().gradeData;
        Initialization();
        print(a);
    }

    void Initialization()
    {
        print("第一个");
        for (int i=0;i<a;i++)
        {
            GameObject bat;
            bat=Instantiate(but);
            bat.transform.parent = parentBut.transform;
            bat.transform.GetChild(0).GetComponent<Text>().text = namestring[i];
            bat.GetComponent<CatalogBut>().a = i;
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
